<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title> - jqGird</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico"> <link th:href="@{../../back/css/bootstrap.min.css?v=3.3.6}" rel="stylesheet">
    <link th:href="@{../../back/css/font-awesome.css?v=4.4.0}" rel="stylesheet">

    <!-- jqgrid-->
    <link th:href="@{../../back/css/plugins/jqgrid/ui.jqgrid.css?0820}" rel="stylesheet">

    <link th:href="@{../../back/css/animate.css}" rel="stylesheet">
    <link th:href="@{../../back/css/style.css?v=4.1.0}" rel="stylesheet">

    <style>
        /* Additional style to fix warning dialog position */

        #alertmod_table_list_2 {
            top: 900px !important;
        }
        .ui-jqgrid .ui-jqgrid-hbox{
            padding-right:0;
        }
        .table.table-bordered{
            width: 100% !important;
        }
    </style>

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content  animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox ">

                <div class="ibox-content">

                    <div class="ibox-content">
                        <form role="form" class="form-inline">
                            <div class="form-group">
                                会员ID：<input type="text" placeholder="请输入会员ID" id="queryMemberId" class="form-control">
                            </div>
                            <button class="btn btn-white" type="button" id="queryButton">查询</button>
                        </form>
                    </div>


                    <div class="jqGrid_wrapper">
                        <table id="table_list_1"></table>
                        <div id="pager_list_1"></div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>


<input type="hidden" id="activityId" />


<div id="activityDetail" class="modal fade" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" >
                    信息详情
                </h4>
            </div>

            <div class="modal-body">
                <div class="row">
                    <div class="col-sm-6 b-r">
                        <form  id="activityDetailForm" role="form">
                            <div class="form-group">
                                <textarea name="authOpinion" placeholder="请输入" class="form-control" ></textarea>
                                <input type="hidden" id="activityDetailId" name="id" />
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>



<div id="publishAudit" class="modal fade" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    信息审核
                </h4>
            </div>

            <div class="modal-body">
                <div class="row">
                    <div class="col-sm-6 b-r">
                        <form  id="publishAuditForm" role="form">
                            <div class="form-group">
                                <label>审核意见：</label>
                                <textarea name="approvalOpinion" placeholder="请输入" class="form-control" ></textarea>
                                <input type="hidden" id="publishInfoAuditId" name="entityId" />
                                <input type="hidden"  name="entityType" value="PUBLISH_INFO" />
                                <input type="hidden" id="publishAuditStateInput" name="auditState"/>
                            </div>
                        </form>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button"   onclick="publishAudit('AUDIT_PASS')" class="btn btn-primary">
                        审核通过
                    </button>
                    <button type="button"  onclick="publishAudit('AUDIT_FAIL')" class="btn btn-default"  >
                        审核不通过
                    </button>
                </div>
            </div>
        </div>
    </div>

</div>

<script th:inline="javascript">
    /*<![CDATA[*/
    ctxPath = /*[[@{/}]]*/ '';
    /*]]>*/


    function publishAudit(authState) {
        if(!window.confirm("确认审核?")){
            return;
        }
        $('#publishAuditStateInput').val(authState);
        var url ="../audit/audit.action" ;
        $.ajax({
            type: "post",
            url: url,
            data: $('#publishAuditForm').serialize(),
            dataType: "json",
            async: false,
            success: function (data) {
                if(data!=null && data.success){
                    alert("审核成功!");
                    $("#table_list_1").trigger("reloadGrid");
                }else {
                    alert(data.message);
                }

            }
        });
        // });
    }
</script>


<!-- 全局js -->
<script th:src="@{../../back/js/jquery.min.js?v=2.1.4}"></script>
<script th:src="@{../../back/js/bootstrap.min.js?v=3.3.6}"></script>



<!-- Peity -->
<script th:src="@{../../back/js/plugins/peity/jquery.peity.min.js}"></script>
<!-- jqGrid -->
<script th:src="@{../../back/js/plugins/jqgrid/i18n/grid.locale-cn.js?0820}"></script>
<script th:src="@{../../back/js/plugins/jqgrid/jquery.jqGrid.min.js?0820}"></script>

<!-- 自定义js -->
<script  th:src="@{../../back/js/content.js?v=1.0.0}"></script>

<!-- layerDate plugin javascript -->
<script th:src="@{../../back/js/plugins/layer/laydate/laydate.js}"></script>


<script th:inline="javascript">
    /*<![CDATA[*/
    ctxPath = /*[[@{/}]]*/ '';
    /*]]>*/
</script>
<!-- Page-Level Scripts -->
<script>
    $(document).ready(function () {
        $.jgrid.defaults.styleUI = 'Bootstrap';
        // Configuration for jqGrid Example 1
        $("#table_list_1").jqGrid({
            url:ctxPath+'back/publishInfo/applyPublishInfoList.action',
            mtype:"POST",
            datatype: "json",
            sortname : 'createTime',
            sortorder : "desc",
            height: 550,
            autowidth: true,
            shrinkToFit: true,
            rowNum: 10,
            rowList: [10, 20, 30],
            colNames: [ '序号','消息名称','申请时间','申请状态', '操作'],
            colModel: [
                {
                    name: 'id',
                    index: 'id',
                },
                {
                    name: 'infoName',
                    index: 'infoName',
                },
                {
                    name: 'applicantTime',
                    index: 'applicantTime',
                    sorttype: "date",
                    formatter: "date"
                },
                {
                    name: 'infoStatus',
                    index: 'infoStatus',
                    formatter: infoStatusFormatter

                },
                {
                    name: 'note',
                    index: 'note',
                    sortable: false,
                    align: "center",
                    sortable: false,
                    editable: false,
                    formatter: alarmFormatter
                }
            ],
            pager: "#pager_list_1",
            viewrecords: true,
            jsonReader: {
                root : "resultList", // 服务端保存数据的集合
                id: "id", //相当于设置主键
                total: "pageSize",　　 //总页数
                page: "currentPage",　　//当前页
                records: "totalRecord",//总记录数
                repeatitems: false,
                cell: "resultList"

            },
            caption: "发布信息申请",
            hidegrid: false
        });


        $(function(){



            $("#queryButton").click(function(){
                var memberId = escape($("#queryMemberId").val());

                $("#table_list_1").jqGrid('setGridParam', {
                    url: ctxPath+'back/publishInfo/applyPublishInfoList.action',
                    postData:{'memberId':memberId}, //发送数据
                    page: 1
                }).trigger("reloadGrid");

            });
        });


        //自定义格式列格式
        function alarmFormatter(cellvalue, options, rowObject){
            var imageHtml =" <input data-toggle='modal' data-target='#publishAudit' onclick=\"showPublishAudit("+rowObject.id+")\" type='button' value='审核'  />&nbsp;&nbsp;" +
                "<input data-toggle='modal' data-target='#activityDetail' onclick=\"showDetail("+rowObject.id+")\" type='button' value='详情'  />&nbsp;&nbsp;";
            "<input data-toggle='modal' data-target='#publishActivity' type='button' value='发布'  />";
            return imageHtml;
        }

        //自定义格式列格式
        function infoStatusFormatter(cellvalue, options, rowObject){
            if(cellvalue=="UN_AUDIT"){
                return "申请待审核";
            }else if(cellvalue=="APPLY_CANCEL"){
                return "申请取消";
            }else if(cellvalue=="AUDIT_PASS"){
                return "申请审核通过";
            }else if(cellvalue=="AUDIT_FAIL"){
                return "申请审核不通过";
            }else if(cellvalue=="INFO_SIGN_UP"){
                return "信息报名中";
            }else if(cellvalue=="INFO_IN_PROGRESS"){
                return "信息实施进行中";
            }else if(cellvalue=="INFO_CANCEL"){
                return "信息取消";
            }else if(cellvalue=="INFO_FINISHED"){
                return "信息结束";
            }else if(cellvalue=="INFO_APPRECIATED"){
                return "信息已打赏";
            }else{
                return cellvalue;
            }
        }


        // Add responsive to jqGrid
        $(window).bind('resize', function () {
            var width = $('.jqGrid_wrapper').width()+18;
            $('#table_list_1').setGridWidth(width);
            $('#table_list_2').setGridWidth(width);
        });
    });


    function showPublishAudit(rowId){
        $('#publishInfoAuditId').val(rowId);
    }


    function showDetail(rowId){
        $.ajax({
            type: "post",
            url: ctxPath+'back/publishInfo/queryPublishInfoDetailById.action',
            data:{'id':rowId},
            dataType: "json",
            async: false,
            success: function (data) {
                if(data!=null && data.success){
                    $('#noticeContent').attr('readonly',false);
                    $('#noticeContent').val(data.result);

                }else {
                    alert(data.message);
                }
            }
        });

    }


</script>


</body>

</html>
